import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/task/process_vetting_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/task/process_vetting_config_entity.dart';


ProcessVettingEntity $ProcessVettingEntityFromJson(Map<String, dynamic> json) {
  final ProcessVettingEntity processVettingEntity = ProcessVettingEntity();
  final List<ProcessVettingHead>? head = (json['head'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ProcessVettingHead>(e) as ProcessVettingHead).toList();
  if (head != null) {
    processVettingEntity.head = head;
  }
  final List<dynamic>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (data != null) {
    processVettingEntity.data = data;
  }
  return processVettingEntity;
}

Map<String, dynamic> $ProcessVettingEntityToJson(ProcessVettingEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['head'] = entity.head?.map((v) => v.toJson()).toList();
  data['data'] = entity.data;
  return data;
}

extension ProcessVettingEntityExtension on ProcessVettingEntity {
  ProcessVettingEntity copyWith({
    List<ProcessVettingHead>? head,
    List<dynamic>? data,
  }) {
    return ProcessVettingEntity()
      ..head = head ?? this.head
      ..data = data ?? this.data;
  }
}

ProcessVettingHead $ProcessVettingHeadFromJson(Map<String, dynamic> json) {
  final ProcessVettingHead processVettingHead = ProcessVettingHead();
  final String? label = jsonConvert.convert<String>(json['label']);
  if (label != null) {
    processVettingHead.label = label;
  }
  final String? field = jsonConvert.convert<String>(json['field']);
  if (field != null) {
    processVettingHead.field = field;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    processVettingHead.type = type;
  }
  final ProcessVettingConfigEntity? config = jsonConvert.convert<ProcessVettingConfigEntity>(json['config']);
  if (config != null) {
    processVettingHead.config = config;
  }
  return processVettingHead;
}

Map<String, dynamic> $ProcessVettingHeadToJson(ProcessVettingHead entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['label'] = entity.label;
  data['field'] = entity.field;
  data['type'] = entity.type;
  data['config'] = entity.config?.toJson();
  return data;
}

extension ProcessVettingHeadExtension on ProcessVettingHead {
  ProcessVettingHead copyWith({
    String? label,
    String? field,
    String? type,
    ProcessVettingConfigEntity? config,
  }) {
    return ProcessVettingHead()
      ..label = label ?? this.label
      ..field = field ?? this.field
      ..type = type ?? this.type
      ..config = config ?? this.config;
  }
}

ProcessVettingData $ProcessVettingDataFromJson(Map<String, dynamic> json) {
  final ProcessVettingData processVettingData = ProcessVettingData();
  final String? value = jsonConvert.convert<String>(json['value']);
  if (value != null) {
    processVettingData.value = value;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    processVettingData.id = id;
  }
  final String? processId = jsonConvert.convert<String>(json['processId']);
  if (processId != null) {
    processVettingData.processId = processId;
  }
  final String? dictionaryTableId = jsonConvert.convert<String>(json['dictionaryTableId']);
  if (dictionaryTableId != null) {
    processVettingData.dictionaryTableId = dictionaryTableId;
  }
  return processVettingData;
}

Map<String, dynamic> $ProcessVettingDataToJson(ProcessVettingData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['value'] = entity.value;
  data['id'] = entity.id;
  data['processId'] = entity.processId;
  data['dictionaryTableId'] = entity.dictionaryTableId;
  return data;
}

extension ProcessVettingDataExtension on ProcessVettingData {
  ProcessVettingData copyWith({
    String? value,
    String? id,
    String? processId,
    String? dictionaryTableId,
  }) {
    return ProcessVettingData()
      ..value = value ?? this.value
      ..id = id ?? this.id
      ..processId = processId ?? this.processId
      ..dictionaryTableId = dictionaryTableId ?? this.dictionaryTableId;
  }
}
